package com.njupt.swg.controller;

import com.njupt.swg.pojo.EasyUITreeNode;
import com.njupt.swg.pojo.TaotaoResult;
import com.njupt.swg.service.ContentCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("")
public class ContentCategoryController {
    @Autowired
    private ContentCategoryService contentCategoryService;

    @RequestMapping("/content/category/list")
    @ResponseBody
    public List<EasyUITreeNode> getContentList(@RequestParam(value = "id",defaultValue = "0")long parentId){
        return contentCategoryService.getContentCategoryList(parentId);
    }

    @RequestMapping("/content/category/create")
    @ResponseBody
    public TaotaoResult getContentList(@RequestParam(value = "parentId",defaultValue = "0")long parentId,String name){
        return contentCategoryService.addContentCategory(parentId,name);
    }
}
